package com.example.sort;

import java.util.Arrays;

/**
 * 选择排序
 * @author zhanpengguo
 * @date 2019-07-30 16:16
 */
public class XuanZe {

    public static Integer[] sort(Integer[] arrays) {
        Integer[] ints = Arrays.copyOf(arrays, arrays.length);
        for (int i = 0; i < ints.length; i++) {
            int min = i;
            for (int j = i; j < ints.length; j++) {
                if (ints[j] < ints[min]) {
                    min = j;
                }
            }
            int temp = ints[i];
            ints[i] = ints[min];
            ints[min] = temp;
        }
        return ints;
    }
}
